import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yt_devops/components/app_bar/app_bar_widget.dart';
import 'package:yt_devops/components/brn/brn_input_text.dart';
import 'package:yt_devops/components/yt_button.dart';
import 'package:yt_devops/components/yt_form/utils/form_widget_utils.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';
import 'text_input_controller.dart';

class TextInputPage extends GetView<TextInputController> {
  const TextInputPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBarWidget.defaultAppBar(controller.fieldProps.title),
      body: GetBuilder<TextInputController>(
        builder: (controller) => Container(
          margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 16.h),
          child: Column(children: [
            FormWidgetUtils.getHeadTitleWidget(controller.fieldProps.title,
                required: controller.fieldProps.requireStar,
                labelStyle: TextStyles.f16.boldStyle),
            YBrnInputText(
              padding: EdgeInsets.fromLTRB(16.w, 16.h, 12.w, 12.w),
              bgColor: controller.fieldProps.bgColor,
              autoFocus: false,
              minHeight: controller.fieldProps.minHeight,
              maxLength: controller.fieldProps.maxLength,
              minLines: controller.fieldProps.minLines,
              hint: controller.fieldProps.hint,
              textString: controller.fieldProps.textString,
              textEditingController: controller.textEditingController,
              onTextChange: (input) => controller.onChange(input),
              onSubmit: (input) => controller.submit(),
            ),
            Expanded(
              child: Align(
                alignment: Alignment.bottomCenter,
                child: SafeArea(
                  child: YtButton(
                    enabled: controller.enable,
                    text: ResKey.submit.tr,
                    onPress: controller.submit,
                  ),
                ),
              ),
            ),
          ]),
        ),
      ),
    );
  }
}
